\(\int \cos (c+d x) (a+i a \tan (c+d x))^2 \, dx\) [31]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 22, antiderivative size = 46 \[ \int \cos (c+d x) (a+i a \tan (c+d x))^2 \, dx=-\frac {a^2 \text {arctanh}(\sin (c+d x))}{d}-\frac {2 i \cos (c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{d} \]

[Out]

-a^2*arctanh(sin(d*x+c))/d-2*I*cos(d*x+c)*(a^2+I*a^2*tan(d*x+c))/d

Rubi [A] (verified)

Time = 0.05 (sec) , antiderivative size = 46, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.091, Rules used = {3577, 3855} \[ \int \cos (c+d x) (a+i a \tan (c+d x))^2 \, dx=-\frac {a^2 \text {arctanh}(\sin (c+d x))}{d}-\frac {2 i \cos (c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{d} \]

[In]

Int[Cos[c + d*x]*(a + I*a*Tan[c + d*x])^2,x]

[Out]

-((a^2*ArcTanh[Sin[c + d*x]])/d) - ((2*I)*Cos[c + d*x]*(a^2 + I*a^2*Tan[c + d*x]))/d

Rule 3577

Int[((d_.)*sec[(e_.) + (f_.)*(x_)])^(m_)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[2*b*(d
*Sec[e + f*x])^m*((a + b*Tan[e + f*x])^(n - 1)/(f*m)), x] - Dist[b^2*((m + 2*n - 2)/(d^2*m)), Int[(d*Sec[e + f
*x])^(m + 2)*(a + b*Tan[e + f*x])^(n - 2), x], x] /; FreeQ[{a, b, d, e, f}, x] && EqQ[a^2 + b^2, 0] && GtQ[n,
1] && ((IGtQ[n/2, 0] && ILtQ[m - 1/2, 0]) || (EqQ[n, 2] && LtQ[m, 0]) || (LeQ[m, -1] && GtQ[m + n, 0]) || (ILt
Q[m, 0] && LtQ[m/2 + n - 1, 0] && IntegerQ[n]) || (EqQ[n, 3/2] && EqQ[m, -2^(-1)])) && IntegerQ[2*m]

Rule 3855

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps \begin{align*} \text {integral}& = -\frac {2 i \cos (c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{d}-a^2 \int \sec (c+d x) \, dx \\ & = -\frac {a^2 \text {arctanh}(\sin (c+d x))}{d}-\frac {2 i \cos (c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{d} \\ \end{align*}

Mathematica [B] (verified)

Both result and optimal contain complex but leaf count is larger than twice the leaf count of optimal. \(180\) vs. \(2(46)=92\).

Time = 0.52 (sec) , antiderivative size = 180, normalized size of antiderivative = 3.91 \[ \int \cos (c+d x) (a+i a \tan (c+d x))^2 \, dx=\frac {a^2 \left (\cos \left (\frac {1}{2} (c+d x)\right ) \left (-2 i+\log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )-\log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )\right )+\left (2-i \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )+i \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )\right ) \sin \left (\frac {1}{2} (c+d x)\right )\right ) \left (\cos \left (\frac {1}{2} (c+5 d x)\right )+i \sin \left (\frac {1}{2} (c+5 d x)\right )\right )}{d (\cos (d x)+i \sin (d x))^2} \]

[In]

Integrate[Cos[c + d*x]*(a + I*a*Tan[c + d*x])^2,x]

[Out]

(a^2*(Cos[(c + d*x)/2]*(-2*I + Log[Cos[(c + d*x)/2] - Sin[(c + d*x)/2]] - Log[Cos[(c + d*x)/2] + Sin[(c + d*x)
/2]]) + (2 - I*Log[Cos[(c + d*x)/2] - Sin[(c + d*x)/2]] + I*Log[Cos[(c + d*x)/2] + Sin[(c + d*x)/2]])*Sin[(c +
 d*x)/2])*(Cos[(c + 5*d*x)/2] + I*Sin[(c + 5*d*x)/2]))/(d*(Cos[d*x] + I*Sin[d*x])^2)

Maple [A] (verified)

Time = 0.63 (sec) , antiderivative size = 56, normalized size of antiderivative = 1.22

method result size
derivativedivides \(\frac {-a^{2} \left (-\sin \left (d x +c \right )+\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )\right )-2 i a^{2} \cos \left (d x +c \right )+a^{2} \sin \left (d x +c \right )}{d}\) \(56\)
default \(\frac {-a^{2} \left (-\sin \left (d x +c \right )+\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )\right )-2 i a^{2} \cos \left (d x +c \right )+a^{2} \sin \left (d x +c \right )}{d}\) \(56\)
risch \(-\frac {2 i a^{2} {\mathrm e}^{i \left (d x +c \right )}}{d}+\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{d}-\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{d}\) \(61\)

[In]

int(cos(d*x+c)*(a+I*a*tan(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

1/d*(-a^2*(-sin(d*x+c)+ln(sec(d*x+c)+tan(d*x+c)))-2*I*a^2*cos(d*x+c)+a^2*sin(d*x+c))

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 52, normalized size of antiderivative = 1.13 \[ \int \cos (c+d x) (a+i a \tan (c+d x))^2 \, dx=\frac {-2 i \, a^{2} e^{\left (i \, d x + i \, c\right )} - a^{2} \log \left (e^{\left (i \, d x + i \, c\right )} + i\right ) + a^{2} \log \left (e^{\left (i \, d x + i \, c\right )} - i\right )}{d} \]

[In]

integrate(cos(d*x+c)*(a+I*a*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

(-2*I*a^2*e^(I*d*x + I*c) - a^2*log(e^(I*d*x + I*c) + I) + a^2*log(e^(I*d*x + I*c) - I))/d

Sympy [A] (verification not implemented)

Time = 0.18 (sec) , antiderivative size = 68, normalized size of antiderivative = 1.48 \[ \int \cos (c+d x) (a+i a \tan (c+d x))^2 \, dx=\frac {a^{2} \left (\log {\left (e^{i d x} - i e^{- i c} \right )} - \log {\left (e^{i d x} + i e^{- i c} \right )}\right )}{d} + \begin {cases} - \frac {2 i a^{2} e^{i c} e^{i d x}}{d} & \text {for}\: d \neq 0 \\2 a^{2} x e^{i c} & \text {otherwise} \end {cases} \]

[In]

integrate(cos(d*x+c)*(a+I*a*tan(d*x+c))**2,x)

[Out]

a**2*(log(exp(I*d*x) - I*exp(-I*c)) - log(exp(I*d*x) + I*exp(-I*c)))/d + Piecewise((-2*I*a**2*exp(I*c)*exp(I*d
*x)/d, Ne(d, 0)), (2*a**2*x*exp(I*c), True))

Maxima [A] (verification not implemented)

none

Time = 0.36 (sec) , antiderivative size = 61, normalized size of antiderivative = 1.33 \[ \int \cos (c+d x) (a+i a \tan (c+d x))^2 \, dx=-\frac {a^{2} {\left (\log \left (\sin \left (d x + c\right ) + 1\right ) - \log \left (\sin \left (d x + c\right ) - 1\right ) - 2 \, \sin \left (d x + c\right )\right )} + 4 i \, a^{2} \cos \left (d x + c\right ) - 2 \, a^{2} \sin \left (d x + c\right )}{2 \, d} \]

[In]

integrate(cos(d*x+c)*(a+I*a*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

-1/2*(a^2*(log(sin(d*x + c) + 1) - log(sin(d*x + c) - 1) - 2*sin(d*x + c)) + 4*I*a^2*cos(d*x + c) - 2*a^2*sin(
d*x + c))/d

Giac [A] (verification not implemented)

none

Time = 0.46 (sec) , antiderivative size = 56, normalized size of antiderivative = 1.22 \[ \int \cos (c+d x) (a+i a \tan (c+d x))^2 \, dx=\frac {-2 i \, a^{2} e^{\left (i \, d x + i \, c\right )} - a^{2} \log \left (i \, e^{\left (i \, d x + i \, c\right )} - 1\right ) + a^{2} \log \left (-i \, e^{\left (i \, d x + i \, c\right )} - 1\right )}{d} \]

[In]

integrate(cos(d*x+c)*(a+I*a*tan(d*x+c))^2,x, algorithm="giac")

[Out]

(-2*I*a^2*e^(I*d*x + I*c) - a^2*log(I*e^(I*d*x + I*c) - 1) + a^2*log(-I*e^(I*d*x + I*c) - 1))/d

Mupad [B] (verification not implemented)

Time = 3.75 (sec) , antiderivative size = 41, normalized size of antiderivative = 0.89 \[ \int \cos (c+d x) (a+i a \tan (c+d x))^2 \, dx=-\frac {2\,a^2\,\mathrm {atanh}\left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )}{d}+\frac {4\,a^2}{d\,\left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )+1{}\mathrm {i}\right )} \]

[In]

int(cos(c + d*x)*(a + a*tan(c + d*x)*1i)^2,x)

[Out]

(4*a^2)/(d*(tan(c/2 + (d*x)/2) + 1i)) - (2*a^2*atanh(tan(c/2 + (d*x)/2)))/d